﻿using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class informDAL : PageDAL<EmployeeModel>
    {
        public EmployeeModel GetModelByID(string tableName, int pid)
        {
            string sql = $"select * from  {tableName} where id='{pid}'";
            DataTable dt = new DBHelper().GetDataTable(sql);
            EmployeeModel model = new EmployeeModel()
            {

                ID = int.Parse(dt.Rows[0]["id"].ToString()),
                EmployeeName = dt.Rows[0]["EmployeeName"].ToString(),
                Age = dt.Rows[0]["Age"].ToString(),
                Sex = dt.Rows[0]["Sex"].ToString(),
                Address = dt.Rows[0]["Address"].ToString(),
                Call = dt.Rows[0]["Call"].ToString(),
                Wages = dt.Rows[0]["Wages"].ToString()

            };
            return model;
        }

        public DataTable Xs(string tableName, int id)
        {
            string sql = $"select* from {tableName} where EmployeeTypeID = '{id}'";
            return new DBHelper().GetDataTable(sql);
        }
        public DataTable SelectName(string TableName, string mz,int id)
        {
            string sql = $"select * from {TableName} where EmployeeName like '%{mz}%' and EmployeeTypeID='{id}'";
            return new DBHelper().GetDataTable(sql);
        }
    }
}
